<template>
  <div class="app-container">
    <el-row >
      <el-col :span="8"  >
        <p><b>通用变量</b></p>
        <pre class="el-card code-preview">
date: String yyyy-MM-dd
time: String HH:mm:ss
author: String 服务器用户名
connectProperties: Map
  url: String 连接数据库 url
  username: String 连接数据库用户名
  driverClassName: String 驱动类名
        </pre>
      </el-col>
      <el-col :span="8" class="">
        <p><b>单文件生成变量列表(多表)</b></p>
        <pre class="code-preview el-card">
tables: List&lt;TableMetaData&gt;  数据表列表
  actualTableName: ActualTableName 表名信息
    namespace: Namespace
      catalog: String
      schema: String
    tableName: String
  table: Table
    actualTableName: ActualTableName
    remark: String
  columns: List&lt;Column&gt;
    actualTableName: ActualTableName
    columnName: String
    dataType: int 字段类型 javax.sql.Types
    typeName: String
    columnSize: int 列长度
    decimalDigits: int 列精度
    nullable: boolean 是否可以空, 真表示可以空
    remark: String,
    autoIncrement: boolean 自增
    defaultValue: String 默认值
  indices: List&lt;Index&gt; 索引信息
    actualTableName: ActualTableName
    unique: boolean
    indexName: String
    indexType: short
    ordinalPosition: short
    columnName: String
  primaryKeys: List&lt;PrimaryKey&gt;
    actualTableName: ActualTableName
    columnName: String
    keySeq: int
    pkName: String

        </pre>
      </el-col>
      <el-col :span="8" class="">
        <p><b>多文件生成变量列表(单表)</b></p>
        <pre class="code-preview el-card">
table: TableMetaData
mapping: JavaBeanInfo
  className: String
  lowerClassName: String
  imports: Set&lt;String&gt;
  fields: BeanField
    typeName: String
    fieldName: String
    comment: String
    key: boolean
    column: Column
    capitalName: String
package: PackageConfig
  parent: String
  mapper: String
  service: String
  controller: String
  entity: String
  vo: String
  dto: String
  param: String
        </pre>
      </el-col>
    </el-row>
    <el-tabs :active-name="tabs.activeTabName" tab-position="top">
      <el-tab-pane v-for="example in examples"  :name="example.key" :label="example.key" :key="example.key">
        <pre class="code-preview">{{example.value}}</pre>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import database from '@/api/database'

export default {
  name: 'TemplateExample',
  data(){
    return {
      tabs: {
        activeTabName: 'example-0'
      },
      examples: [],
    }
  },
  methods: {

  },
  mounted() {
    database.templateExamples().then(res => {
      this.examples = res.data;

      if (this.examples.length > 0){
        this.tabs.activeTabName = this.examples[0].key
      }

    })
  }
}
</script>

<style scoped>
.code-preview{
  line-height: 1.5;
}
.el-card{
  padding: 2px;
  height: 50vh;
  overflow-y: scroll;
}
</style>
